﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>{PageTitle}</title>
</head>
<body>
    <script type="text/javascript">
        function addSite() {
            $('#SiteList').datagrid('unselectAll');
            $('#win').window('open');
            
        }
        function editSite() {
            var row = $('#SiteList').datagrid('getSelected');
            if (row) {
                var index = $('#SiteList').datagrid('getRowIndex', row);
                $('#SiteList').datagrid('beginEdit', index);
            }
        }
        function saveSite() {
            var row = $('#SiteList').datagrid('getSelected');
            if (row) {
                var index = $('#SiteList').datagrid('getRowIndex', row);
                $('#SiteList').datagrid('endEdit', index);
                $.post("~/admin/sso/saveSite", row);
                cancelSite();
            }
            else {
                if ($('#SiteName').val()!="") {
                    $.post("~/admin/sso/saveSite", { SiteName: $('#SiteName').val(), SiteAdd: $('#SiteAdd').val(), Group: $('#Group').val(), CreateDate: "",CreateUser:"" });
                    $('#win').window('close');
                    cancelSite();
                }
            }
        }
        function delteSite() {
            var row = $('#SiteList').datagrid('getSelected');
            if (row) {
                $.post("~/admin/sso/delSite", {ID:row.ID});
                cancelSite();
            }
            
        }
        function cancelSite() {
            $('#SiteList').datagrid('reload');
        }
    </script>
    <table id="SiteList" class="easyui-datagrid" url="~/admin/sso/getsitelist" pagination="true"
        idfield="ID" singleselect="true" toolbar="#tools" pagesize="30" rownumbers="true">
        <thead>
            <tr>
                <!--<th field="ID" editor="text" width="60px">
                    编号
                </th>-->
                <th field="SiteName" width="100px" editor="text">
                    站点名称
                </th>
                <th field="SiteAdd" width="300px" editor="text">
                    站点地址
                </th>
                <th field="Group" width="135px" editor="text">
                    站群
                </th>
                <th field="CreateUser" width="100px">
                    创建者
                </th>
                <th field="CreateDate" width="130px">
                    创建时间
                </th>
            </tr>
        </thead>
    </table>
    <div id="tools">
        <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addSite()">
            增加</a><a href="#" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="saveSite()">
                保存</a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editSite()">
                    修改</a> <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="delteSite()">
                        删除</a> <a href="#" class="easyui-linkbutton" iconcls="icon-undo" plain="true" onclick="cancelSite()">
                            撤销</a>
    </div>
    <div id="win" class="easyui-window" closed="true" modal="true" iconcls="icon-save"
        title="添加站点" style="width: 300px; height: 200px; padding: 5px;">
        <div>
            <label for="SiteName">
                站点名称:</label>
            <input type="text" id="SiteName" name="SiteName"/>
        </div>
        <div>
            <label for="SiteAdd">
                站点地址:</label>
            <input class="easyui-validatebox" type="text" name="SiteAdd" id="SiteAdd" required="true"/>
        </div>
        <div>
            <label for="Group">
                所属站群:</label>
            <input class="easyui-validatebox" type="text" id="Group" name="Group"/>
        </div>
        <a href="#" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="saveSite()">
            保存</a> <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" plain="true" onclick="$('#win').window('close')">
                关闭</a>
    </div>
</body>
</html>
